<template>
  <div class="p-2">
    <el-row :gutter="20">
      <el-col :lg="24" :xs="24">
        <div v-show="showSearch" class="mb-[10px]">
          <el-card shadow="hover">
            <el-form ref="queryFormRef" :model="queryParams" :inline="true">
              <el-form-item label="用户名称" prop="userName">
                <el-input v-model="queryParams.userName" placeholder="请输入用户名称" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
                <el-button icon="Refresh" @click="resetQuery">重置</el-button>
              </el-form-item>
            </el-form>
          </el-card>
        </div>

        <el-card shadow="hover">
          <template #header>
            <el-row :gutter="10">
              <el-col :span="1.5">
                <el-button type="primary" plain icon="Plus" @click="handleAdd()">新增</el-button>
              </el-col>
              <right-toolbar v-model:show-search="showSearch" :columns="columns" :search="true" @query-table="getList"></right-toolbar>
            </el-row>
          </template>

          <el-table v-loading="loading" border :data="listData" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="50" align="center" />
            <template v-for="(item, index) in columns">
              <el-table-column v-if="item.visible"
                               :key="item.key"
                               :label="item.label"
                               align="center"
                               :width="item.width"
                               :prop="item.key" >
                <template v-slot="scope">
                  <template v-if="item.key === '样品状态'">
                    <el-tag type="danger">{{ scope.row[item.key] }}</el-tag>
                  </template>
                </template>
              </el-table-column>
            </template>

            <el-table-column label="操作" fixed="right" width="180" align="center">
              <template #default="scope">
                <el-button link type="primary" icon="View">查看</el-button>
              </template>
            </el-table-column>
          </el-table>

          <pagination
            v-show="total > 0"
            v-model:page="queryParams.pageNum"
            v-model:limit="queryParams.pageSize"
            :total="total"
            @pagination="getList"
          />
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script setup>
// 方法
import { ref } from 'vue'
// 列显隐信息
const columns = ref([
  { key: '检验记录ID', label: '检验记录ID', visible: true, width: 150, children: [] },
  { key: '样品ID', label: '样品ID', visible: true, width: 150, children: [] },
  { key: '样品名称', label: '样品名称', visible: true, width: 180, children: [] },
  { key: '采样日期', label: '采样日期', visible: true, width: 120, children: [] },
  { key: '采样地点', label: '采样地点', visible: true, width: 150, children: [] },
  { key: '采样人员', label: '采样人员', visible: true, width: 120, children: [] },
  { key: '样品状态', label: '样品状态', visible: true, width: 120, children: [] },
  { key: '检验人员', label: '检验人员', visible: true, width: 120, children: [] },
  { key: '检验日期', label: '检验日期', visible: true, width: 120, children: [] },
  { key: '检验项目', label: '检验项目', visible: true, width: 120, children: [] },
  { key: '检验方法', label: '检验方法', visible: true, width: 120, children: [] },
  { key: '检测仪器', label: '检测仪器', visible: true, width: 150, children: [] },
  { key: '检验结果', label: '检验结果', visible: true, width: 120, children: [] },
  { key: '结果单位', label: '结果单位', visible: true, width: 120, children: [] },
  { key: '标准限值', label: '标准限值', visible: true, width: 120, children: [] },
  { key: '结果判定', label: '结果判定', visible: true, width: 120, children: [] },
  { key: '检出限', label: '检出限', visible: true, width: 120, children: [] },
  { key: '备注信息', label: '备注信息', visible: true, width: 120, children: [] },
  { key: '质控措施', label: '质控措施', visible: true, width: 120, children: [] },
  { key: '质控结果', label: '质控结果', visible: true, width: 120, children: [] },
  { key: '数据来源', label: '数据来源', visible: true, width: 120, children: [] },
  { key: '更新时间', label: '更新时间', visible: true, width: 120, children: [] },
  { key: '创建时间', label: '创建时间', visible: true, width: 120, children: [] }
]);

const queryParams = ref({
  pageNum: 1,
  pageSize: 10,
})
const total = ref(0)
const showSearch = ref(true);
const loading = ref(true);
const listData = ref([
  {
    "检验记录ID": "JYX20250701001",
    "样品ID": "YP20250701A01",
    "样品名称": "长江武汉段表层水",
    "采样日期": "2025-07-01 08:30:00",
    "采样地点": "长江武汉段汉口江滩采样点",
    "采样人员": "张三",
    "样品状态": "异常",
    "检验人员": "李四",
    "检验日期": "2025-07-02 10:15:00",
    "检验项目": "pH值",
    "检验方法": "GB/T 6920-1986",
    "检测仪器": "雷磁pH计 PHS-3E",
    "检验结果": 7.25,
    "结果单位": "无量纲",
    "标准限值": 6.5,
    "结果判定": "合格",
    "检出限": 0.01,
    "备注信息": "样品清澈无异味",
    "质控措施": "平行样",
    "质控结果": "相对偏差2.1%",
    "数据来源": "实验室自测",
    "更新时间": "2025-07-02 14:30:00",
    "创建时间": "2025-07-01 09:00:00"
  },
  {
    "检验记录ID": "JYX20250701002",
    "样品ID": "YP20250701A01",
    "样品名称": "长江武汉段表层水",
    "采样日期": "2025-07-01 08:30:00",
    "采样地点": "长江武汉段汉口江滩采样点",
    "采样人员": "张三",
    "样品状态": "异常",
    "检验人员": "李四",
    "检验日期": "2025-07-02 11:40:00",
    "检验项目": "化学需氧量(COD)",
    "检验方法": "HJ 828-2017",
    "检测仪器": "连华科技COD测定仪LH-10B",
    "检验结果": 18.7,
    "结果单位": "mg/L",
    "标准限值": 20,
    "结果判定": "合格",
    "检出限": 0.5,
    "备注信息": "消解时间延长5分钟",
    "质控措施": "加标回收",
    "质控结果": "回收率96.5%",
    "数据来源": "实验室自测",
    "更新时间": "2025-07-02 15:10:00",
    "创建时间": "2025-07-01 09:00:00"
  },
  {
    "检验记录ID": "JYX20250701003",
    "样品ID": "YP20250701A01",
    "样品名称": "长江武汉段表层水",
    "采样日期": "2025-07-01 08:30:00",
    "采样地点": "长江武汉段汉口江滩采样点",
    "采样人员": "张三",
    "样品状态": "异常",
    "检验人员": "李四",
    "检验日期": "2025-07-02 14:20:00",
    "检验项目": "氨氮",
    "检验方法": "HJ 535-2009",
    "检测仪器": "紫外可见分光光度计UV-1800",
    "检验结果": 0.85,
    "结果单位": "mg/L",
    "标准限值": 1.0,
    "结果判定": "合格",
    "检出限": 0.025,
    "备注信息": "蒸馏过程无异常",
    "质控措施": "空白对照",
    "质控结果": "空白值0.012mg/L",
    "数据来源": "实验室自测",
    "更新时间": "2025-07-02 16:30:00",
    "创建时间": "2025-07-01 09:00:00"
  },
  {
    "检验记录ID": "JYX20250702001",
    "样品ID": "YP20250702B01",
    "样品名称": "东湖风景区湖心水",
    "采样日期": "2025-07-02 10:15:00",
    "采样地点": "北京密云水库饮用水源地",
    "采样人员": "王五",
    "样品状态": "异常",
    "检验人员": "赵六",
    "检验日期": "2025-07-03 09:30:00",
    "检验项目": "溶解氧(DO)",
    "检验方法": "HJ 506-2009",
    "检测仪器": "哈希溶解氧仪HQ40d",
    "检验结果": 7.3,
    "结果单位": "mg/L",
    "标准限值": 5,
    "结果判定": "合格",
    "检出限": 0.1,
    "备注信息": "现场固定后立即送检",
    "质控措施": "平行样",
    "质控结果": "相对偏差1.8%",
    "数据来源": "实验室自测",
    "更新时间": "2025-07-03 11:45:00",
    "创建时间": "2025-07-02 10:30:00"
  },
  {
    "检验记录ID": "JYX20250702002",
    "样品ID": "YP20250702B01",
    "样品名称": "东湖风景区湖心水",
    "采样日期": "2025-07-02 10:15:00",
    "采样地点": "广州珠江新城污水处理厂总排口",
    "采样人员": "王五",
    "样品状态": "异常",
    "检验人员": "赵六",
    "检验日期": "2025-07-03 13:00:00",
    "检验项目": "总磷",
    "检验方法": "GB/T 11893-1989",
    "检测仪器": "紫外可见分光光度计UV-1800",
    "检验结果": 0.12,
    "结果单位": "mg/L",
    "标准限值": 0.2,
    "结果判定": "合格",
    "检出限": 0.01,
    "备注信息": "过硫酸钾消解完全",
    "质控措施": "加标回收",
    "质控结果": "回收率92.3%",
    "数据来源": "实验室自测",
    "更新时间": "2025-07-03 15:20:00",
    "创建时间": "2025-07-02 10:30:00"
  },
  {
    "检验记录ID": "JYX20250703001",
    "样品ID": "YP20250703C01",
    "样品名称": "某化工园区废水排放口",
    "采样日期": "2025-07-03 14:45:00",
    "采样地点": "化工园区污水处理厂总排口",
    "采样人员": "钱七",
    "样品状态": "异常",
    "检验人员": "孙八",
    "检验日期": "2025-07-04 10:00:00",
    "检验项目": "pH值",
    "检验方法": "GB/T 6920-1986",
    "检测仪器": "雷磁pH计 PHS-3E",
    "检验结果": 4.8,
    "结果单位": "无量纲",
    "标准限值": 6,
    "结果判定": "超标",
    "检出限": 0.01,
    "备注信息": "样品呈酸性，有刺激性气味",
    "质控措施": "平行样",
    "质控结果": "相对偏差1.5%",
    "数据来源": "实验室自测",
    "更新时间": "2025-07-04 13:10:00",
    "创建时间": "2025-07-03 15:10:00"
  },
  {
    "检验记录ID": "JYX20250703002",
    "样品ID": "YP20250703C01",
    "样品名称": "某化工园区废水排放口",
    "采样日期": "2025-07-03 14:45:00",
    "采样地点": "化工园区污水处理厂总排口",
    "采样人员": "钱七",
    "样品状态": "异常",
    "检验人员": "孙八",
    "检验日期": "2025-07-04 14:20:00",
    "检验项目": "化学需氧量(COD)",
    "检验方法": "HJ 828-2017",
    "检测仪器": "连华科技COD测定仪LH-10B",
    "检验结果": 85.6,
    "结果单位": "mg/L",
    "标准限值": 50,
    "结果判定": "超标",
    "检出限": 0.5,
    "备注信息": "样品需稀释10倍测定",
    "质控措施": "加标回收",
    "质控结果": "回收率98.7%",
    "数据来源": "实验室自测",
    "更新时间": "2025-07-04 16:40:00",
    "创建时间": "2025-07-03 15:10:00"
  },
  {
    "检验记录ID": "JYX20250704001",
    "样品ID": "YP20250704D01",
    "样品名称": "某饮用水源地取水口",
    "采样日期": "2025-07-04 09:30:00",
    "采样地点": "饮用水源一级保护区",
    "采样人员": "周九",
    "样品状态": "异常",
    "检验人员": "吴十",
    "检验日期": "2025-07-05 11:15:00",
    "检验项目": "浊度",
    "检验方法": "HJ 1075-2019",
    "检测仪器": "哈希浊度仪2100Q",
    "检验结果": 0.3,
    "结果单位": "NTU",
    "标准限值": 1,
    "结果判定": "合格",
    "检出限": 0.01,
    "备注信息": "样品澄清透明",
    "质控措施": "空白对照",
    "质控结果": "空白值0.02NTU",
    "数据来源": "实验室自测",
    "更新时间": "2025-07-05 14:20:00",
    "创建时间": "2025-07-04 10:00:00"
  },
  {
    "检验记录ID": "JYX20250704002",
    "样品ID": "YP20250704D01",
    "样品名称": "某饮用水源地取水口",
    "采样日期": "2025-07-04 09:30:00",
    "采样地点": "饮用水源一级保护区",
    "采样人员": "周九",
    "样品状态": "异常",
    "检验人员": "吴十",
    "检验日期": "2025-07-05 15:30:00",
    "检验项目": "总大肠菌群",
    "检验方法": "GB/T 5750.12-2006",
    "检测仪器": "生化培养箱SPX-250B",
    "检验结果": "未检出",
    "结果单位": "MPN/100mL",
    "标准限值": "不得检出",
    "结果判定": "合格",
    "检出限": 3,
    "备注信息": "采用多管发酵法",
    "质控措施": "阳性对照",
    "质控结果": "阳性对照正常生长",
    "数据来源": "实验室自测",
    "更新时间": "2025-07-05 17:00:00",
    "创建时间": "2025-07-04 10:00:00"
  },
]);


// 获取数据
const getList = () => {
  loading.value = false
}

// 搜索
const handleQuery = () => {
}

// 重置
const resetQuery = () => {
  for (let i in queryParams.value) {
    if (i !== 'pageNum' && i !== 'pageSize') {
      queryParams.value[i] = undefined
    }
  }
  handleQuery()
}

// 多选
const handleSelectionChange = () => {
}

// 新增
const handleAdd = () => {
}


getList()
</script>
